//
// Created by lzw on 24-10-19.
//

#include <stdio.h>
#include <string.h>
#include "token.h"

void s_token_set_type(struct s_token *t, const char *typ) { strcpy(t->type, typ); }

void s_token_set_literal(struct s_token *t, const char *literal) { strcpy(t->literal, literal); }
void s_token_to_str(struct s_token *t, char *str) { sprintf(str, "{type: %s, literal: %s}", t->type, t->literal); }


struct s_token new_s_token(const char *typ, const char *literal)
{
    struct s_token t;
    strcpy(t.type, typ);
    strcpy(t.literal, literal);
    return t;
}

int s_token_eq(const struct s_token t1, const struct s_token t2)
{
    if (strcmp(t1.type, t2.type) == 0)
    {
        if (strcmp(t1.literal, t2.literal) == 0)
        {
            return 1;
        }
    }
    return 0;
}